package org.example;

import org.example.service.BookService;
import org.example.service.impl.BookServiceImpl;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;


public class Main {
    public static void main(String[] args) {
        /*
        普通版本，代码耦合

        BookService bookService = new BookServiceImpl();
        bookService.save();
        */
        // 3.获取Ioc容器
        ApplicationContext ctx = new ClassPathXmlApplicationContext("applicationContext.xml");
        // 4.从Ioc容器中获取Bean
        BookService bookService = (BookService) ctx.getBean("bookService");
        bookService.save();
    }
}